#!/bin/bash

tf="rep.cnf.zds"
tfk="rep.cnf.zds.bak"
rm -rf $tf $tfk

for rip in `seq 0 0`
do
    ip=`printf "172.23.112.87"`

    for rdb in `seq 0 0`
    do
        let dbx=(rip-43)*2+rdb
        db=`printf "zdstest"`
        for rtbl in `seq 0 31`
        do
            let tblx=rtbl
            tbl=`printf auction_tag_%03d $tblx`
    	    echo "master|$ip|3306|M:$db|$db|$tbl|dump|dump123|mysql-bin.00000|106|/u01/cm5_zds" | tee -a $tfk
        done
    
        table_list=("deploy_job" "dump_job" "preview_job")
        for tbl in ${table_list[@]}
        do
	        echo "master|$ip|3306|M:$db|$db|$tbl|dump|dump123|mysql-bin.00000|106|/u01/cm5_zds" | tee -a $tfk
        done
    done
done
echo "slave|172.25.89.28|3306|S:feel:feed_auc_count_xxx|cm5_zds|cm5_zds|repsync|repsync123|0|0" | tee -a $tfk


start=1
row_diff=34
let end=start+row_diff

while read line 
do
    binfile=`echo "$line" | cut -f1`
    cat $tfk | sed -n "${start},${end}p" | sed "s/mysql-bin.00000|/${binfile}|/"  | tee -a $tf
    let start=end+1
    let end=start+row_diff
done < "sync_pos.log"

tail -1 $tfk >> $tf
